<template>
    <div class="main">
        <el-carousel class="shopdateils" indicator-position="outside" height="570px" :autoplay="notflow">
            <el-carousel-item v-for="(item,index) in group.color" :key="index" autoplay="false">
                <div class="card">
                    <div class="img"><img :src="group.url[index]" alt=""></div>
                    <div class="information">
                        <p class="name">{{ group.name }}</p>
                        <p class="introduce">{{ group.introdus }}</p>
                        <p style="color: orange; font-size: 13px; margin-bottom: 3px;">小米自营</p>
                        <hr>
                        <p class="title">内存 / 价格</p>
                        <div class="size hover"><p v-for="(items , index) in group.sizes" :key="index">{{ items.size }}  {{ items.prices }}</p></div>                          
                        <p class="title" style="margin-top: 36px;">颜色</p>
                        <div class="hover"><p class="color">{{ item }}</p></div>
                        <div class="bottom hover" @click="upData">
                            <p class="more" @click="gohttpUp(group.name)">前往商品页面<i class="el-icon-d-arrow-right"></i></p>  
                        </div>
                    </div>
                </div>  
            </el-carousel-item>
        </el-carousel>
    </div>
</template>

<script>

import axios from "axios";
export default{
 name: 'shopdateils',
 components: {},
 
 data(){
    return{
        newvalue:0,
        notflow:false,
        group:{},
        shop:[],
        commodityListvalue:{
            index:0,
            id:0
        },
        commodity:[]
    }
 },
 methods:{ 
    upData(){    
        axios.get('http://localhost:3001/mindex/0').then((res) => {
                this.newvalue = Number(res.data.index)
                this.group = this.commodity[this.newvalue]
            })
    },
    gohttpUp(name){
        if(name=='Redmi k60'|| name=='Redmi k60 Pro'|| name=='Redmi Note 12 Pro 极速版'|| name=='Xiaomi 13 Pro'|| name=='Xiaomi 13'|| name=='Xiaomi 13 限量定制色'){
            this.commodityListvalue.index = 0
            axios.patch('http://localhost:3001/mishowlistindex/0', this.commodityListvalue).then(()=>{
                this.$router.push('miphone')
            })
        }else if(name=='Redmi G Pro 游戏本'|| name=='Redmi G Pro 游戏本 2022 锐龙版'|| name=='Redmi Pad'|| name=='Redmi Book Pro 15 2022 锐龙版'|| name=='小米平板5 Pro'|| name=='小米平板5 Pro 12.4' || name =='Redmi Book Pro 14 2022'){
            this.commodityListvalue.index = 1
            axios.patch('http://localhost:3001/mishowlistindex/0', this.commodityListvalue).then(()=>{
                this.$router.push('miphone')
            })
        }else{
            this.commodityListvalue.index = 2
            axios.patch('http://localhost:3001/mishowlistindex/0', this.commodityListvalue).then(()=>{
                this.$router.push('miphone')
            })
        }
    }
 },
  mounted(){
    axios.get('http://localhost:3001/firstCommodity').then((res) => {
                this.commodity = res.data
                this.upData()
            })

 },  
 
 watch:{   
 }
};
</script>

<style scoped lang='less'>
.main{
    height: 700px;
    width: 100%;
    position: relative;
    margin: auto;
    top: 80px;
    .el-carousel__item{
        .card{
            height: 100%;
            width: 1200px;
            position: relative;
            margin: auto;
            .img{
                height: 100%;
                width: 540px;
                padding: 60px;
                float: left;
                img{
                    width: 100%;
                    height: 100%;
                } 
            }
            .information{
                height: 100%;
                width: 660px;
                padding: 70px;
                float: left;
                .hover :hover{
                    color:orange;
                    border-color: orange;
                }
                .name{
                    font-size: 28px;
                    font-weight: 600;
                    margin-bottom: 30px;
                    letter-spacing: 2px;
                }
                .introduce{
                    font-size: 13px;
                    margin-bottom: 17px;
                    letter-spacing: 1px;
                    color: gray;
                }
                .title{
                    width: 100px;
                    height: 30px;
                    float: none;
                    font-size: 19px;
                    color: gray;
                    margin: 20px 0 5px 0;
                }
                .size{
                    width: 500px;
                    height: 33%;
                    white-space: nowrap; 
                    p{
                        overflow: hidden;
                        float: left;
                        width: 220px;
                        height: 33%;
                        font-size:100%;
                        border: 1px solid gray;
                        border-radius: 5px;
                        line-height: 45px;
                        margin: 4px 10px 4px 20px;
                        text-align: center;
                    }
                }
                .color{
                    width: 220px;
                    height: 45px;
                    text-align: center;
                    border: 1px solid gray;
                    border-radius: 5px;
                    line-height: 45px; 
                    margin: 2px 10px 4px 20px;
                }
                .bottom{
                    width: 200px;
                    height: 30px;
                    margin: 24px 0 0 350px;
                    font-size: 17px; 
                }
            }
        }
    }
}
  .el-carousel__item:nth-child(n) {
    background-color: #eaedf0;
  }
</style>